//package com.plian.system.service.fr.evaluation.impl;
//
//import cn.hutool.core.lang.Assert;
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.itextpdf.text.pdf.AcroFields;
//import com.itextpdf.text.pdf.BaseFont;
//import com.itextpdf.text.pdf.PdfReader;
//import com.itextpdf.text.pdf.PdfStamper;
//import com.plian.Tools.*;
//import com.plian.Tools.pagedata.PageData;
//import com.plian.system.constant.sys.FormStatusConstant;
//import com.plian.system.constant.sys.FormTypeConstant;
//import com.plian.system.dto.fr.evaluation.AssetEvaluationApprovalDTO;
//import com.plian.system.entity.fr.evaluation.Appraiser;
//import com.plian.system.entity.fr.evaluation.AssetEvaluationApproval;
//import com.plian.system.entity.fr.evaluation.AssetEvaluationReport;
//import com.plian.system.mapper.fr.evaluation.AssetEvaluationApprovalMapper;
//import com.plian.system.mapper.fr.evaluation.AssetEvaluationReportMapper;
//import com.plian.system.mapper.fr.evaluation.QualityEvaluationMapper;
//import com.plian.system.model.CommonCode;
//import com.plian.system.model.ListResult;
//import com.plian.system.mybatis.base.BaseFlowService;
//import com.plian.system.mybatis.base.BaseServiceImpl;
//import com.plian.system.mybatis.search.SearchEntity;
//import com.plian.system.mybatis.support.Condition;
//import com.plian.system.mybatis.support.Query;
//import com.plian.system.pdf.OutPdf;
//import com.plian.system.service.fr.evaluation.IAppraiserService;
//import com.plian.system.service.fr.evaluation.IAssetEvaluationApprovalService;
//import com.plian.system.service.pm.property.IPropertyBasicsService;
//import com.plian.system.service.sys.code.IFormCodeService;
//import com.plian.system.service.sys.file.FileService;
//import com.plian.system.service.sys.orgzation.IOrgService;
//import com.plian.system.service.sys.orgzation.OrgzationService;
//import com.plian.system.service.wf.FormWorkflowService;
//import com.plian.system.vo.fr.evaluation.ApprovedInfoVO;
//import com.plian.system.vo.fr.evaluation.AssetEvaluationApprovalVO;
//import com.plian.system.vo.fr.evaluation.AssetEvaluationReportVO;
//import com.plian.system.wrapper.fr.evaluation.AssetEvaluationApprovalWrapper;
//import com.plian.system.wrapper.fr.evaluation.AssetEvaluationReportWrapper;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.io.FileUtils;
//import org.apache.commons.io.IOUtils;
//import org.apache.commons.lang.exception.ExceptionUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.flowable.ui.common.service.exception.BadRequestException;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.io.*;
//import java.util.*;
//import java.util.stream.Collectors;
//
//import static com.plian.system.constant.sys.FormStatusConstant.UNREVIEWED;
//import static com.plian.system.constant.sys.FormTypeConstant.FR_ASSET_EVALUATION_APPROVAL;
//import static com.plian.system.pdf.OutPdf.processDate;
//
///**
// * <p>
// * 资产评估报告核准 服务实现类
// * </p>
// *
// * @author hu song
// * @since 2023-03-29 14:31:06
// */
//@Slf4j
//@Service
//@RequiredArgsConstructor
//public class AssetEvaluationApprovalServiceImpl extends BaseServiceImpl<AssetEvaluationApprovalMapper, AssetEvaluationApproval> implements IAssetEvaluationApprovalService, BaseFlowService {
//
//    private final AssetEvaluationApprovalMapper assetEvaluationApprovalMapper;
//    private final AssetEvaluationApprovalWrapper assetEvaluationApprovalWrapper;
//    private final AssetEvaluationReportMapper assetEvaluationReportMapper;
//    private final AssetEvaluationReportWrapper assetEvaluationReportWrapper;
//    private final IFormCodeService formCodeService;
//    private final IPropertyBasicsService propertyBasicsService;
//    private final FormWorkflowService formWorkflowService;
//    private final FileService fileService;
//    private final IAppraiserService appraiserService;
//    private final QualityEvaluationMapper qualityEvaluationMapper;
//    private final IOrgService orgService;
//    private final OrgzationService orgzationService;
//
//
//    @Override
//    public ListResult<AssetEvaluationApprovalVO> findAll(Query query) {
//        ListResult<AssetEvaluationApprovalVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//        List<SearchEntity> entityList = query.getSearch();
//
//        AssetEvaluationApprovalDTO dto = new AssetEvaluationApprovalDTO();
//        if (CollectionUtil.isNotEmpty(entityList)) {
//            for (SearchEntity searchEntity : entityList) {
//                if (searchEntity.getField().equals("declare_unit_id")) {
//                    List<String> unitIds = (List<String>) searchEntity.getValue();
//                    dto.setDeclareUnitIds(unitIds);
//                }
//                if (searchEntity.getField().equals("name")) {
//                    dto.setName(String.valueOf(searchEntity.getValue()));
//                }
//            }
//        }
//
//        String orgId = TokenUtil.getTokenOrgId();
//        dto.setCreateCompanyId(TokenUtil.getTokenOrgId());
//        if (query!= null && query.getFlag() != null && query.getFlag() == 1){
//            if (!orgService.checkIsGzw(orgId)){
//                List<String> allChildIds = orgService.getAllChildIds(orgId);
//                dto.setChildCompanyIds(allChildIds);
//            }
//            dto.setFlag(1);
//        }
//
//        IPage<AssetEvaluationApproval> page = assetEvaluationApprovalMapper.findPage(Condition.getPage(query), dto);
//        if (page.getSize() == -1) {
//            page.setTotal(page.getRecords().size());
//        }
//        listResult.setList(assetEvaluationApprovalWrapper.entityToVO(page.getRecords()));
//        Optional.ofNullable(listResult.getList()).ifPresent(item -> {
//            item.forEach(assetEvaluationApprovalVO -> {
//                assetEvaluationApprovalVO.setAssetEvaluationReportVO(assetEvaluationReportWrapper.entityToVO(assetEvaluationApprovalVO.getAssetEvaluationReportVO()));
//            });
//        });
//        listResult.setTotal((int) page.getTotal());
//        return listResult;
//    }
//
//    @Override
//    public AssetEvaluationApprovalVO detail(AssetEvaluationApproval assetEvaluationApproval) {
//        Assert.notNull(assetEvaluationApproval.getId(), "id不能为空");
//        AssetEvaluationApprovalVO assetEvaluationApprovalVO = Optional.ofNullable(assetEvaluationApprovalWrapper.entityToVO(assetEvaluationApprovalMapper.findById(assetEvaluationApproval.getId()))).orElseThrow(() -> new BadRequestException("资产评估报告核准数据不存在"));
//        assetEvaluationApprovalVO.setAssetEvaluationReportVO(assetEvaluationReportWrapper.entityToVO(assetEvaluationApprovalVO.getAssetEvaluationReportVO()));
//        return assetEvaluationApprovalVO;
//    }
//
//    @Override
//    @Transactional(rollbackFor = Exception.class)
//    public boolean saveOrUpdate(AssetEvaluationApproval entity) {
//
//        // 检查主要事项是否存在
//        AssetEvaluationReport assetEvaluationReport = Optional.ofNullable(assetEvaluationReportMapper.selectById(entity.getAssetEvaluationReportId())).orElseThrow(() -> new BadRequestException("资产评估主要事项报备数据不存在"));
//        boolean isSaveFlag = false;
//        if (entity.getId() == null) {
//            isSaveFlag = true;
//            entity.setFormType(String.valueOf(FormTypeConstant.FR_ASSET_EVALUATION_APPROVAL));
//            entity.setApprovalCode("邢国资评核（备）" + formCodeService.getFilingCode(FormTypeConstant.FR_ASSET_EVALUATION_APPROVAL) + "号");
//            entity.setCompanyLevel(propertyBasicsService.findByOrgId(assetEvaluationReport.getDeclareUnitId()).getPropertyLevel());
//            entity.setCode(formCodeService.getCode(FormTypeConstant.FR_ASSET_EVALUATION_APPROVAL));
//        }
//
//        boolean result = super.saveOrUpdate(entity);
//
//        // 评估师
//        List<Appraiser> appraisers = entity.getAppraisers();
//        if (CollectionUtil.isNotEmpty(appraisers)) {
//            appraisers.forEach(appraiser -> {
//                appraiser.setAssetEvaluationApprovalId(entity.getId());
//            });
//            if (!isSaveFlag) {
//                appraiserService.remove(new LambdaQueryWrapper<Appraiser>().eq(Appraiser::getAssetEvaluationApprovalId, entity.getId()));
//            }
//            appraiserService.saveBatch(appraisers);
//        }
//        // 启动流程
//        if (isSaveFlag && Objects.equals(entity.getFormType(), FormTypeConstant.FR_ASSET_EVALUATION_APPROVAL)) {
//            HashMap<String, Object> processVariable = new HashMap<>();
//            formWorkflowService.startProcessAndSimulate(String.valueOf(entity.getId()), entity.getFormType(), processVariable);
//        }
//
//        // 附件
//        if (CollectionUtil.isNotEmpty(entity.getDocList())) {
//            if (isSaveFlag) {
//                fileService.saveAll(String.valueOf(entity.getId()), entity.getDocList());
//            } else {
//                fileService.edit(String.valueOf(entity.getId()), entity.getDocList());
//            }
//        }
//        return result;
//    }
//
//    @Transactional(rollbackFor = Exception.class)
//    public Boolean handleStatus(Long id, int updateStatus) {
//        try {
//            AssetEvaluationApproval assetEvaluationApproval = getById(id);
//            /**
//             * 设置审批人和审批时间
//             */
//            if (updateStatus == FormStatusConstant.FINISH) {
//                assetEvaluationApproval.setGzApprovedUser(TokenUtil.getTokenUserId());
//                Date now = DateUtil.now();
//                assetEvaluationApproval.setGzApprovedTime(now);
//
//            }
//            assetEvaluationApproval.setStatus(updateStatus);
//            updateById(assetEvaluationApproval);
//            log.info("更新[资产评估报告核准]id=" + id + "状态为: " + updateStatus + "");
//            return true;
//        } catch (Exception e) {
//            log.error(ExceptionUtils.getFullStackTrace(e));
//            return false;
//        }
//    }
//
//    @Override
//    public HashMap<String,Object> commit(String id) {
//        handleStatus(Long.valueOf(id), FormStatusConstant.FLOW);
//
//        //将需要提交的流程变量返回，用于工作流侧
//        return new HashMap<String,Object>();
//    }
//
//    @Override
//    public Boolean finish(String id) {
//        return handleStatus(Long.valueOf(id), FormStatusConstant.FINISH);
//    }
//
//    @Override
//    public Boolean reject(String id, int formState,String comment) {
//        return handleStatus(Long.valueOf(id), formState);
//    }
//
//    @Override
//    public void goBackToStash(String formId) {
//        handleStatus(Long.valueOf(formId), UNREVIEWED);
//    }
//
//    @Override
//    public List<PageData> findByIds(List<String> formIds) {
//        LambdaQueryWrapper<AssetEvaluationApproval> queryWrapper = new LambdaQueryWrapper<>();
//        queryWrapper.in(AssetEvaluationApproval::getId, Func.toLongList(StringUtils.join(formIds, StringPool.COMMA)));
//        List<AssetEvaluationApproval> assetEvaluationApprovals = list(queryWrapper);
//        List<AssetEvaluationApprovalVO> assetEvaluationApprovalVOs = assetEvaluationApprovalWrapper.entityToVO(assetEvaluationApprovals);
//        List<PageData> pageDataList = new ArrayList<>();
//        try {
//            if (CollectionUtil.isNotEmpty(assetEvaluationApprovalVOs)) {
//                for (AssetEvaluationApprovalVO vo : assetEvaluationApprovalVOs) {
//                    PageData pd = new PageData();
//                    AssetEvaluationReportVO reportVO = assetEvaluationReportWrapper.entityToVO(assetEvaluationReportMapper.selectById(vo.getAssetEvaluationReportId()));
//
//                    if (reportVO != null) {
//                        // 集团名称
//                        pd.put("UNITNAME", reportVO.getDeclareUnitName());
//                        pd.put("applyOrganizationId", reportVO.getDeclareUnitId());
//                        // 企业名称
//                        pd.put("orgName", reportVO.getDeclareUnitName());
//                    }
//                    pd.put("id", vo.getId());
//                    pd.put("APPLICANTNAME", vo.getCreateUserName());
//                    pd.put("applicantId", vo.getCreateUser());
//                    pd.put("formType", vo.getFormType());
//                    pageDataList.add(pd);
//                }
//            }
//
//            return pageDataList;
//        } catch (Exception e) {
//            log.error(ExceptionUtils.getFullStackTrace(e));
//        }
//        return pageDataList;
//    }
//
//    @Override
//    public List<Integer> getFormType() {
//        return Arrays.asList(FR_ASSET_EVALUATION_APPROVAL);
//    }
//
//    @Override
//    @Transactional(rollbackFor = Exception.class)
//    public boolean saveAuditInfo(AssetEvaluationApproval resource) {
//        Assert.notNull(resource.getId(), "id不能为空");
//        ApprovedInfoVO approvedInfoVO = resource.getApprovedInfoVO();
//        Assert.notNull(approvedInfoVO, "审批信息不能为空");
//        AssetEvaluationApproval assetEvaluationApproval = Optional.ofNullable(getById(resource.getId())).orElseThrow(() -> new BadRequestException("资产评估报告核准数据不存在"));
//        // 申报单位
//        if (Objects.equals(TokenUtil.getTokenOrgId(), resource.getAssetEvaluationReportVO().getDeclareUnitId())) {
//            assetEvaluationApproval.setDeclareUnitApprovedUser(approvedInfoVO.getApprovedUser());
//            assetEvaluationApproval.setDeclareUnitApprovedOpeinion(approvedInfoVO.getApprovedOpeinion());
//            assetEvaluationApproval.setDeclareUnitApprovedTime(approvedInfoVO.getApprovedTime());
//            assetEvaluationApproval.setDeclareUnitApprovedSeal(approvedInfoVO.getApprovedImageId());
//        }
//
//        // 集团
//        if (Objects.equals(resource.getAssetEvaluationReportVO().getDeclareUnitId(), orgzationService.getUnitId(TokenUtil.getTokenOrgId()))) {
//            assetEvaluationApproval.setGroupApprovedUser(approvedInfoVO.getApprovedUser());
//            assetEvaluationApproval.setGroupApprovedOpeinion(approvedInfoVO.getApprovedOpeinion());
//            assetEvaluationApproval.setGroupApprovedTime(approvedInfoVO.getApprovedTime());
//            assetEvaluationApproval.setGroupApprovedSeal(approvedInfoVO.getApprovedImageId());
//        }
//        // 国资
//        if (Objects.equals(true, orgService.checkIsGzw(TokenUtil.getTokenOrgId()))) {
//            assetEvaluationApproval.setGzApprovedUser(approvedInfoVO.getApprovedUser());
//            assetEvaluationApproval.setGzApprovedOpeinion(approvedInfoVO.getApprovedOpeinion());
//            assetEvaluationApproval.setGzApprovedTime(approvedInfoVO.getApprovedTime());
//            assetEvaluationApproval.setGzApprovedSeal(approvedInfoVO.getApprovedImageId());
//        }
//        // 附件
//        if (CollectionUtil.isNotEmpty(resource.getDocList())) {
//            fileService.edit(String.valueOf(resource.getId()), resource.getDocList());
//        }
//        return updateById(assetEvaluationApproval);
//    }
//
//    @Override
//    public File exportPdf(AssetEvaluationApproval assetEvaluationApproval) {
//        AssetEvaluationApprovalVO bean;
//        if (Objects.nonNull(assetEvaluationApproval.getId())) {
//            bean = assetEvaluationApprovalWrapper.entityToVO(assetEvaluationApprovalMapper.findById(assetEvaluationApproval.getId()));
//        } else {
//            bean = assetEvaluationApprovalWrapper.entityToVO(assetEvaluationApproval);
//        }
//        File file = null;
//
//        try {
//            InputStream inputStream = this.getClass().getResourceAsStream("/pdf/assetEvaluationApproval.pdf");
//            //通过将文件转换为临时文件进行操作
//            File model = File.createTempFile("model", ".png");
//            try {
//                FileUtils.copyInputStreamToFile(inputStream, model);
//            } finally {
//                //关闭IO
//                IOUtils.closeQuietly(inputStream);
//            }
//
//            if (bean != null && model.exists()) {
//                Map<String, Object> data = OutPdf.beanToMap(bean);
//                data.put("declareUnitName", bean.getAssetEvaluationReportVO().getDeclareUnitName());
//                data.put("name", bean.getAssetEvaluationReportVO().getName());
//                data.put("reportNumber", bean.getAssetEvaluationReportVO().getReportNumber());
//                // 账面价值
//                if (StringUtils.isNotEmpty(bean.getBookValue())) {
//                    JSONObject jsonObject = JSON.parseObject(bean.getBookValue());
//                    data.put("bookValueTotalAssetsStr", jsonObject.getString("totalAssets"));
//                    data.put("bookValueTotalResponsibleAmountStr", jsonObject.getString("totalResponsibleAmount"));
//                    data.put("bookValueTotalNetAssetsStr", jsonObject.getString("totalNetAssets"));
//                }
//
//                // 评估结果
//                if (StringUtils.isNotEmpty(bean.getEvaluationResult())) {
//                    JSONObject jsonObject = JSON.parseObject(bean.getBookValue());
//                    data.put("evaluationResultTotalAssetsStr", jsonObject.getString("totalAssets"));
//                    data.put("evaluationResultTotalResponsibleAmountStr", jsonObject.getString("totalResponsibleAmount"));
//                    data.put("evaluationResultTotalNetAssetsStr", jsonObject.getString("totalNetAssets"));
//                }
//
//                // 申报单位联系人及电话
//                data.put("contactPersonAndPhone", (StringUtils.isEmpty(bean.getContactPerson()) ? "" : bean.getContactPerson()) + "，" + (StringUtils.isEmpty(bean.getContactPhone()) ? "" : bean.getContactPhone()));
//
//                // 判断是备案文号还是核准文号
//                String year = String.format("    评核字[%s] 号", Tools.date2Str(DateUtil.now(), "yyyy"));
//                if (Objects.equals(1,assetEvaluationApproval.getApprovalType())) {
//                    data.put("approvalCodeStr",String.format("邢 评核字[%s] 号", year));
//                } else {
//                    data.put("approvalCodeStr", String.format("邢国资评备字[%s]", year));
//                }
//
//                // 审核时间
//                if (Objects.nonNull(bean.getDeclareUnitApprovedTime())) {
//                    data.put("declareUnitApprovedTimeStr", DateUtil.format(bean.getDeclareUnitApprovedTime(), "yyyy年MM月dd日"));
//                }
//                if (Objects.nonNull(bean.getGroupApprovedTime())) {
//                    data.put("groupApprovedTimeStr", DateUtil.format(bean.getGroupApprovedTime(), "yyyy年MM月dd日"));
//                }
//                if (Objects.nonNull(bean.getGzApprovedTime())) {
//                    data.put("gzApprovedTimeStr", DateUtil.format(bean.getGzApprovedTime(), "yyyy年MM月dd日"));
//                }
//
//                // 评估师
//                if (CollectionUtil.isNotEmpty(bean.getAppraisers())) {
//                    StringBuilder builder = new StringBuilder();
//                    for (Appraiser appraiser : bean.getAppraisers()) {
//                        builder.append(StringUtils.isEmpty(appraiser.getName()) ? "" : appraiser.getName()).append("，").append(StringUtils.isEmpty(appraiser.getCertificateNo()) ? "" : appraiser.getCertificateNo()).append("，").append(StringUtils.isEmpty(appraiser.getContact()) ? "" : appraiser.getContact()).append("；");
//                    }
//                    data.put("appraisersStr", builder.toString());
//                }
//
//                String fileName = model.getPath();
//                PdfReader reader = new PdfReader(fileName);
//                ByteArrayOutputStream bos = new ByteArrayOutputStream();
//                /* 将要生成的目标PDF文件名称 */
//                PdfStamper ps = new PdfStamper(reader, bos);
//                /* 使用中文字体 */
//                BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
//                ArrayList<BaseFont> fontList = new ArrayList<>();
//                fontList.add(bf);
//
//                /* 取出报表模板中的所有字段 */
//                AcroFields fields = ps.getAcroFields();
//                fields.setSubstitutionFonts(fontList);
//                for (String key : data.keySet()) {
//                    String value = data.get(key) == null ? null : data.get(key).toString();
//                    if (data.get(key) instanceof Date) {
//                        value = processDate((Date) data.get(key));
//                    }
//                    fields.setField(key, value);
//                }
//
//                /* 必须要调用这个，否则文档不会生成的 */
//                ps.setFormFlattening(true);
//                ps.close();
//                File dir = new File(model.getParent());
//                String classFullName = bean.getClass().getName();
//                file = File.createTempFile(classFullName.substring(classFullName.lastIndexOf(".")), ".pdf", dir);
//                OutputStream fos = new FileOutputStream(file);
//                fos.write(bos.toByteArray());
//                fos.flush();
//                fos.close();
//                bos.close();
//            }
//
//        } catch (Exception e) {
//            log.error(ExceptionUtils.getFullStackTrace(e));
//        }
//        return file;
//    }
//
//    @Override
//    @Transactional(rollbackFor = Exception.class)
//    public boolean addQualityEvaluation(AssetEvaluationApproval resource) {
//        Assert.notNull(resource.getId(), "资产评估报告核准id不能为空");
//        AssetEvaluationApproval assetEvaluationApproval = Optional.ofNullable(getById(resource.getId())).orElseThrow(() -> new BadRequestException("资产评估核准数据不存在"));
//        Assert.isNull(assetEvaluationApproval.getQualityEvaluationId(), "已经做过质量评价");
//        Assert.isTrue(Objects.equals(assetEvaluationApproval.getStatus(), 3), "集团未审批通过，不能做质量评价");
//
//        boolean result = qualityEvaluationMapper.insert(resource.getQualityEvaluation()) > 0;
//        assetEvaluationApproval.setQualityEvaluationId(resource.getQualityEvaluation().getId());
//        updateById(assetEvaluationApproval);
//        return result;
//    }
//
//    @Override
//    public AssetEvaluationApproval getQualityEvaluationById(Long id) {
//        AssetEvaluationApproval assetEvaluationApproval = Optional.ofNullable(getById(id)).orElseThrow(() -> new BadRequestException("资产评估核准数据不存在"));
//        Assert.notNull(assetEvaluationApproval.getQualityEvaluationId(), "未做质量评价");
//        assetEvaluationApproval.setQualityEvaluation(qualityEvaluationMapper.selectById(assetEvaluationApproval.getQualityEvaluationId()));
//        return assetEvaluationApproval;
//    }
//
//    @Override
//    @Transactional(rollbackFor = Exception.class)
//    public boolean deleteLogic(List<Long> ids) {
//        Optional.of(this.list(new QueryWrapper<AssetEvaluationApproval>().in("id", ids))).ifPresent(assetEvaluationApprovals -> {
//            // 删除质量评价
//            List<Long> qualityIds = assetEvaluationApprovals.stream().map(AssetEvaluationApproval::getQualityEvaluationId).collect(Collectors.toList());
//            if (CollectionUtil.isNotEmpty(qualityIds)) {
//                qualityEvaluationMapper.deleteBatchIds(qualityIds);
//            }
//            // 删除评估师
//            List<Long> appraiserIds = assetEvaluationApprovals.stream().map(AssetEvaluationApproval::getAppraisers).filter(CollectionUtil::isNotEmpty).flatMap(Collection::stream).map(Appraiser::getId).collect(Collectors.toList());
//            if (CollectionUtil.isNotEmpty(appraiserIds)) {
//                assetEvaluationApprovalMapper.deleteBatchIds(appraiserIds);
//            }
//        });
//        return super.deleteLogic(ids);
//    }
//
//    @Override
//    public File exportQualityPdf(AssetEvaluationApproval assetEvaluationApproval) {
//        AssetEvaluationApprovalVO bean;
//        if (Objects.nonNull(assetEvaluationApproval.getId())) {
//            bean = assetEvaluationApprovalWrapper.entityToVO(assetEvaluationApprovalMapper.findById(assetEvaluationApproval.getId()));
//            bean.setQualityEvaluation(qualityEvaluationMapper.selectById(bean.getQualityEvaluationId()));
//        } else {
//            bean = assetEvaluationApprovalWrapper.entityToVO(assetEvaluationApproval);
//        }
//
//        File file = null;
//
//        try {
//            InputStream inputStream = this.getClass().getResourceAsStream("/pdf/qualityEvaluation.pdf");
//            //通过将文件转换为临时文件进行操作
//            File model = File.createTempFile("model", ".png");
//            try {
//                FileUtils.copyInputStreamToFile(inputStream, model);
//            } finally {
//                //关闭IO
//                IOUtils.closeQuietly(inputStream);
//            }
//
//            if (model.exists()) {
//                Map<String, Object> data = OutPdf.beanToMap(bean);
//                // 质量评价数据
//                if (Objects.nonNull(bean.getQualityEvaluation())){
//                    data.putAll(OutPdf.beanToMap(bean.getQualityEvaluation()));
//                }
//
//                data.put("name", bean.getAssetEvaluationReportVO().getName());
//                data.put("reportNumber", bean.getAssetEvaluationReportVO().getReportNumber());
//
//                String fileName = model.getPath();
//                PdfReader reader = new PdfReader(fileName);
//                ByteArrayOutputStream bos = new ByteArrayOutputStream();
//                /* 将要生成的目标PDF文件名称 */
//                PdfStamper ps = new PdfStamper(reader, bos);
//                /* 使用中文字体 */
//                BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
//                ArrayList<BaseFont> fontList = new ArrayList<>();
//                fontList.add(bf);
//
//                /* 取出报表模板中的所有字段 */
//                AcroFields fields = ps.getAcroFields();
//                fields.setSubstitutionFonts(fontList);
//                for (String key : data.keySet()) {
//                    String value = data.get(key) == null ? null : data.get(key).toString();
//                    if (data.get(key) instanceof Date) {
//                        value = processDate((Date) data.get(key));
//                    }
//                    fields.setField(key, value);
//                }
//
//                /* 必须要调用这个，否则文档不会生成的 */
//                ps.setFormFlattening(true);
//                ps.close();
//                File dir = new File(model.getParent());
//                String classFullName = bean.getClass().getName();
//                file = File.createTempFile(classFullName.substring(classFullName.lastIndexOf(".")), ".pdf", dir);
//                OutputStream fos = new FileOutputStream(file);
//                fos.write(bos.toByteArray());
//                fos.flush();
//                fos.close();
//                bos.close();
//            }
//
//        } catch (Exception e) {
//            log.error(ExceptionUtils.getFullStackTrace(e));
//        }
//        return file;
//    }
//}
